﻿using System;
using Kent.Boogaart.Truss.Specifications.Support.Entities;

namespace Kent.Boogaart.Truss.Specifications.Support.Converters
{
	public class GenderConverter : IValueConverter
	{
		public object ConvertSourceToTarget(object value, Type type, object parameter)
		{
			return value == null ? null : value.ToString();
		}

		public object ConvertTargetToSource(object value, Type type, object parameter)
		{
			switch (value as string)
			{
				case "Male":
					return Gender.Male;
				case "Female":
					return Gender.Female;
				default:
					throw new InvalidOperationException();
			}
		}
	}
}